package com.five.controller;

import com.five.pojo.ClubActReg;
import com.five.pojo.PageBean;
import com.five.pojo.Result;
import com.five.service.ClubActRegService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.swing.plaf.SeparatorUI;
import java.util.List;

@Tag(name = "报名社团活动学生信息接口")
@RestController
@CrossOrigin
@RequestMapping("/ClubActReg")
public class ClubActRegController {

    @Autowired
    private ClubActRegService clubActRegService;

    @Operation(summary = "查看活动报名信息")
    @GetMapping("/getclubActReg")
    public Result page(@RequestParam(defaultValue = "1") Integer pageNum ,
                       @RequestParam(defaultValue = "2") Integer pageSize,
                       String actName)
    {
        PageBean pageBean = clubActRegService.page(pageNum , pageSize , actName);
        return Result.success(pageBean);
    }


    @Operation(summary = "报名活动")
    @PostMapping("/addPeople")
    public Result addPeople(@RequestBody ClubActReg clubActReg){
        clubActRegService.addPeople(clubActReg);
        return Result.success();
    }

    @Operation(summary = "根据社团名称查活动申请")
    @GetMapping("/getByActClub")
    public Result getByActClub(String actClub){
        List<ClubActReg> clubActRegList = clubActRegService.getByActClub(actClub);
        return Result.success(clubActRegList);
    }

    @Operation(summary = "更新申请活动状态")
    @PutMapping("/ActivityModStatus")
    public Result ActivityModStatus(Integer status , Integer id){
        clubActRegService.updateStatus(status , id);
        if(status == 1){
            return Result.success(1);
        }
        return Result.success(0);
    }

    @Operation(summary = "删除学生的活动申请")
    @DeleteMapping
    public Result delete(Integer id){
        clubActRegService.deleteById(id);
        return Result.success();
    }
}
